package com.xu.mylol.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TabHost;

import com.xu.mylol.R;

/**
 * Created by dllo on 16/1/8.
 */
public class Fragment_Data extends Fragment {
    @Nullable
    private TabHost tabHost;
    private FragmentManager fragmentManager;



    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view =inflater.inflate(R.layout.fragment_data, null);
        tabHost = (TabHost) view.findViewById(android.R.id.tabhost);
        tabHost.setup();

        TabHost.TabSpec tab1 = tabHost.newTabSpec("tab1");
        View view1=inflater.inflate(R.layout.tab_hero,null);
        tab1.setIndicator(view1);
        tab1.setContent(R.id.tab1);
        tabHost.addTab(tab1);

        TabHost.TabSpec tab2 = tabHost.newTabSpec("tab2");
        View view2 =inflater.inflate(R.layout.tab_goods,null);
        tab2.setIndicator(view2);
        tab2.setContent(R.id.tab2);
        tabHost.addTab(tab2);

        TabHost.TabSpec tab3 = tabHost.newTabSpec("tab3");
        View view3 =inflater.inflate(R.layout.tab_gift,null);
        tab3.setIndicator(view3);
        tab3.setContent(R.id.tab3);
        tabHost.addTab(tab3);

        TabHost.TabSpec tab4 = tabHost.newTabSpec("tab4");
        View view4 =inflater.inflate(R.layout.tab_rune,null);
        tab4.setIndicator(view4);
        tab4.setContent(R.id.tab4);
        tabHost.addTab(tab4);

        fragmentManager = getFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.replace(R.id.tab1,new Fragment_Data_Hero());
        transaction.replace(R.id.tab2,new Fragment_Data_Goods());
        transaction.replace(R.id.tab3,new Fragment_Data_Gift());
        transaction.replace(R.id.tab4,new Fragment_Data_Rune());
        transaction.commit();
        return  view;
    }
}
